package com.eco.fanliapp.admin.common;

import com.alibaba.fastjson.JSONObject;
import com.eco.fanliapp.entity.Administrator;
import com.eco.fanliapp.vo.UserVO;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;

public class BaseController{
    public UserVO getAuthentication() {
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        try{
            UserVO userVO = JSONObject.parseObject((String) authentication.getPrincipal(), UserVO.class);
            return userVO;
        }catch (Exception e){

        }
        return null;
    }



    public Administrator getKfAuthentication() {
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        try{
            Administrator imKfInfo = JSONObject.parseObject((String) authentication.getPrincipal(), Administrator.class);
            return imKfInfo;
        }catch (Exception e){

        }
        return null;
    }



}